<template>
  <div>
    <van-swipe :autoplay="3000">
      <van-swipe-item
        v-for="(image, index) in images"
        :key="index"
        class="xian"
      >
        <img v-lazy="image" class="xia" />
      </van-swipe-item>
    </van-swipe>

    <van-icon
      name="browsing-history-o"
      class="brow"
      size="30px
"
      @click="$router.push('/ditu')"
    />

    <div class="ss">
      <van-icon name="arrow-down" class="icon" @click="fn" />
      <button>{{name}}</button>
      <input type="text" value="请输入小区地址" />
      <van-icon class="s" name="search" size="20" color="#9c9fa1" />
    </div>
    <van-grid class="grid">
      <van-grid-item
        icon="wap-home-o"
        text="整租"
        @click="$router.push('/jojo')"
      />
      <van-grid-item
        icon="friends-o"
        text="合租"
        @click="$router.push('/jojo')"
      />
      <van-grid-item
        icon="browsing-history-o"
        text="地图找房"
        @click="$router.push('/ditu')"
      />
      <van-grid-item
        icon="good-job-o"
        text="去出租"
        @click="$router.push('/fbfy')"
      />
    </van-grid>
    <div class="dd">
      <div class="mm">
        <div>租房小组</div>
        <span>更多</span>
      </div>
      <div class="gg">
        <ul>
          <li v-for="item in list" :key="item.id">
            <img :src="'http://liufusong.top:8080' + item.imgSrc" alt="" />
            <p>{{ item.title }}<br />{{ item.desc }}</p>
          </li>
          <!-- <li>
            <img src="" alt="" />
            <p>家住回龙观<br />归属的感觉</p>
          </li>
          <li>
            <img src="" alt="" />
            <p>家住回龙观<br />归属的感觉</p>
          </li>
          <li>
            <img src="" alt="" />
            <p>家住回龙观<br />归属的感觉</p>
          </li> -->
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import { xian } from '../../api/luo'
import { mapState } from 'vuex'
export default {
  data () {
    return {
      images: [
        'http://liufusong.top:8080/img/swiper/2.png',
        'http://liufusong.top:8080/img/swiper/3.png',
        'http://liufusong.top:8080/img/swiper/1.png'
      ],
      list: []
    }
  },
  computed: {
    ...mapState('user', ['name'])
  },
  async created () {
    const data = await xian()
    const { body } = data
    // this.list.push(body)
    this.list = [...this.list, ...body]
    // console.log(body)

    // console.log(data)
  },
  methods: {
    fn () {
      this.$router.push('/lisout')
    }
  }
}
</script>

<style scoped lang="less">
.xian {
  height: 212px;
  // width: 100%;
  .xia {
    width: 100%;
    height: 100%;
  }
}
.brow {
  position: absolute;
  top: 25px;
  right: 15px;
}
.ss {
  height: 40px;
  width: 310px;
  display: flex;
  position: absolute;
  top: 20px;
  // border: 1px solid red;
  left: 15px;
  button {
    height: 100%;
    background-color: #fff;
    border: none;
    padding-right: 20px;
  }
  input {
    height: 38px;
    flex: 1;
    border: none;
    color: #9c9fa1;
    padding-left: 30px;
  }
  .s {
    position: absolute;
    top: 10px;
    left: 80px;
  }
}
.grid {
  height: 121px;
}
.dd {
  background-color: #f6f5f6;
  .mm {
    height: 30px;
    display: flex;
    justify-content: space-between;
    margin: 15px 0 15px 10px;
    padding-top: 20px;
  }
  .gg {
    height: 160px;
    // display: flex;

    ul {
      display: flex;
      flex-wrap: wrap;
      li {
        // flex: 1;
        height: 55px;
        width: 172px;
        // padding-left: 50px;
        background-color: #fff;
        display: flex;
        margin-left: 10px;
        margin-bottom: 20px;
        img {
          width: 50px;
          height: 100%;
          margin-right: 20px;
        }
      }
    }
  }
}
.icon {
  position: relative;
  top: 13px;
  left: 57px;
}
</style>
